class Solution:
    def fourSumCount(self, A: List[int], B: List[int], C: List[int], D: List[int]) -> int:
        mapper1={}
        for i in A:
            try:
                mapper1[i]+=1
            except KeyError:
                mapper1[i]=1
        newmapper={}
        for i in B:
            for j in mapper1.keys():
                try:
                    newmapper[j+i]+=mapper1[j]
                except KeyError:
                    newmapper[j+i]=mapper1[j]
        mapper1=newmapper
        mapper2={}
        for i in C:
            try:
                mapper2[i]+=1
            except KeyError:
                mapper2[i]=1
        newmapper={}
        for i in D:
            for j in mapper2.keys():
                try:
                    newmapper[j+i]+=mapper2[j]
                except KeyError:
                    newmapper[j+i]=mapper2[j]
        mapper2=newmapper
        count=0
        for i in mapper1.keys():
            try:
                count+=mapper1[i]*mapper2[-i]
            except:
                pass
        return count

'''
执行用时：
404 ms
, 在所有 Python3 提交中击败了
30.92%
的用户
内存消耗：
58.6 MB
, 在所有 Python3 提交中击败了
11.95%
的用户
'''

#哈希表可以不用字典了，用collections库